const { newEnforcer } = require('casbin');
const mysql = require('mysql2/promise');
const { BasicAdapter } = require('casbin-basic-adapter');

async function myFunction() {
    // Initialize a Basic adapter and use it in a Node-Casbin enforcer:
    // The adapter can not automatically create database.
    // But the adapter will automatically and use the table named "casbin_rule".
    const a = await BasicAdapter.newAdapter('mysql2',
        mysql.createConnection({
            host: 'localhost',
            user: 'root',
            database: 'taobao',
            password: "root123",
        }));

    const e = await newEnforcer('./rbac_model.conf', a);

    // Check the permission.


}

myFunction()